import { getAppEnvConfig } from '@/utils/env';

const REDIRECT_URL = encodeURIComponent(window.location.href);
const { VITE_GLOB_MAIN_WEB_URL } = getAppEnvConfig();

export const uimsLogin = () => {
  //window.open(
  //  `${VITE_GLOB_MAIN_WEB_URL}/login?domain=eslogis&redirectUri=${REDIRECT_URL}&_=${Math.random().toString(36).substr(2, 9)}`,
  //  '_self', 'noopener=yes,noreferrer=yes'
  //);
  window.location.replace(
    `${VITE_GLOB_MAIN_WEB_URL}/login?domain=eslogis&redirectUri=${REDIRECT_URL}&_=${Math.random().toString(36).substr(2, 9)}`,
  );
};

export const setPassword = () => {
  window.open(
    `${VITE_GLOB_MAIN_WEB_URL}/changePassword?domain=eslogis&redirectUri=${REDIRECT_URL}&_=${Math.random().toString(36).substr(2, 9)}`,
    '_self',
    'noopener=yes,noreferrer=yes',
  );
};

export const changeMobile = () => {
  window.open(
    `${VITE_GLOB_MAIN_WEB_URL}/modifyMobileNumber?domain=eslogis&redirectUri=${REDIRECT_URL}&_=${Math.random().toString(36).substr(2, 9)}`,
    '_self',
    'noopener=yes,noreferrer=yes',
  );
};

export const destroyAccount = () => {
  window.open(
    `${VITE_GLOB_MAIN_WEB_URL}/accountCancellation?domain=eslogis&redirectUri=${REDIRECT_URL}&_=${Math.random().toString(36).substr(2, 9)}`,
    '_self',
    'noopener=yes,noreferrer=yes',
  );
};
